package display;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.springframework.web.context.*;

import domain.*;

import util.*;

public class DetalleArticulo extends PageController {
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		ArticuloRepository articulos = (ArticuloRepository) context.getBean("articuloRepository");
		try {
			String id = request.getParameter("id");
			int idArticulo = Integer.parseInt(id); 
			Articulo articulo = articulos.findArticulo(idArticulo);
			ArticuloDTO dto = ArticuloAssembler.CreateDTO(articulo);
			request.setAttribute("articulo",dto);
			forward("/detalleArticulo.jsp",request,response);
		} catch (Exception e) {
			request.setAttribute("mensaje",e.getMessage());
			forward("/paginaError.jsp",request,response);
		}
	}
}